#include "analysisDialog.h"

AnalysisDialog::AnalysisDialog(Object *_object, Octree *_octree, QWidget *_parent) : QDialog(_parent){
    setWindowTitle(QString::fromUtf8("Análise"));
    QGroupBox *objectGroupBox = NULL;
    if(_object){
        QLabel *objectAreaLabel = new QLabel(QString::fromUtf8("- Área:"));
        QLabel *objectArea = new QLabel(QString::number(_object->area()));

        QHBoxLayout *objectAreaLayout = new QHBoxLayout;
        objectAreaLayout->addWidget(objectAreaLabel);
        objectAreaLayout->addWidget(objectArea);
        objectAreaLayout->addStretch(1);


        QLabel *objectVolumeLabel = new QLabel(QString::fromUtf8("- Volume:"));
        QLabel *objectVolume = new QLabel(QString::number(_object->volume()));

        QHBoxLayout *objectVolumeLayout = new QHBoxLayout;
        objectVolumeLayout->addWidget(objectVolumeLabel);
        objectVolumeLayout->addWidget(objectVolume);
        objectVolumeLayout->addStretch(1);

        QVBoxLayout *objectLayout = new QVBoxLayout;
        objectLayout->addLayout(objectVolumeLayout);
        objectLayout->addLayout(objectAreaLayout);


        objectGroupBox = new QGroupBox(QString::fromUtf8("Primitiva"));
        objectGroupBox->setLayout(objectLayout);
    }
    QGroupBox *octreeGroupBox = NULL;
    if(_octree){
        QLabel *octreeAreaLabel = new QLabel(QString::fromUtf8("- Área:"));

        QLabel *octreeArea = new QLabel(QString::number(_octree->area()));

        QHBoxLayout *octreeAreaLayout = new QHBoxLayout;
        octreeAreaLayout->addWidget(octreeAreaLabel);
        octreeAreaLayout->addWidget(octreeArea);
        octreeAreaLayout->addStretch(1);


        QLabel *octreeVolumeLabel = new QLabel(QString::fromUtf8("- Volume:"));
        QLabel *octreeVolume = new QLabel(QString::number(_octree->volume()));

        QHBoxLayout *octreeVolumeLayout = new QHBoxLayout;
        octreeVolumeLayout->addWidget(octreeVolumeLabel);
        octreeVolumeLayout->addWidget(octreeVolume);
        octreeVolumeLayout->addStretch(1);

        QVBoxLayout *octreeLayout = new QVBoxLayout;
        octreeLayout->addLayout(octreeVolumeLayout);
        octreeLayout->addLayout(octreeAreaLayout);

        octreeGroupBox = new QGroupBox(QString::fromUtf8("Octree"));
        octreeGroupBox->setLayout(octreeLayout);
    }


    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    buttonBox->setLocale(QLocale(QLocale::Portuguese, QLocale::Brazil));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    if(_object) mainLayout->addWidget(objectGroupBox);
    if(_octree) mainLayout->addWidget(octreeGroupBox);
    mainLayout->addWidget(buttonBox);
    mainLayout->addStretch(1);

    setLayout(mainLayout);
}

AnalysisDialog::~AnalysisDialog(){
}
